#define _CRT_SECURE_NO_WARNINGS
class Solution {
public:
    int lengthOfLongestSubstring(string s) {
        map<char, int> mp;
        int right = 0, left = 0, len = 0;
        while (right < s.size())
        {
            mp[s[right]]++;
            while (mp[s[right]] > 1)
            {
                mp[s[left++]]--;
            }
            len = max(len, right - left + 1);
            right++;
        }
        return len;
    }
};